import { request, config } from 'utils'

const { api, defaultPageSize } = config
const { resource } = api

export async function query(params = {}) {
  const limit = params.queryParam.limit ? params.queryParam.limit : defaultPageSize;
  const start = params.queryParam.start ? params.queryParam.start + 1 : 1;
  const url = `${resource}/list/${limit}/${start}/${params.sort}/${params.order}/complex`;
  return request({ url: url, method: 'PUT', data: params.queryParam })
}
export async function update(params = {}) {
  const url = `${resource}/update`;
  return request({ url: url, method: 'PUT', data: params })
}
export async function add(params = {}) {
  const url = `${resource}/create`;
  return request({ url: url, method: 'POST', data: params })
}
export async function deleteResource(params = {}) {
  const url = `${resource}/delete/${params.id}/${params.version}`;
  return request({ url: url, method: 'POST', data: {} })
}
